feat(cloud): bound the imported-replay prefix blind spot with a re-anchor cadence - #700
Merged
Merged
Conversation
The bounded incremental path cannot detect a historical rewrite that preserves every provider turn id outside its reread overlap; until now that blind spot lasted until some other invariant happened to fail. The checkpoint gains an incrementalPassCount (optional; absent reads as 0), and after 64 consecutive bounded passes the preparer declines the checkpoint so the pass takes the full authoritative read: an intact prefix validates against the chain commitment and rides the ordinary delta append with a fresh count-0 checkpoint, while genuine prefix mutation is caught at the bounded horizon and pays the designed epoch rewrite. The forced reread amortizes O(total) I/O to under 2% of passes and uploads nothing by itself. Pre-commit hook ran. Total eslint: 18, total circular: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#692's bounded incremental path validates ordered turn ids, a Merkle frontier, and the reread overlap — but a historical rewrite that preserves every provider-native turn id outside the overlap is undetectable from the compact checkpoint, and the PR documented that blind spot as lasting "until another invariant fails or a future full re-anchor occurs". Nothing scheduled that re-anchor, so the window was unbounded.
Solution
ImportedReplayCheckpointgains an optionalincrementalPassCount(absent reads as 0, so persisted checkpoints stay compatible in both directions). Each bounded pass increments it; atIMPORTED_INCREMENTAL_REANCHOR_EVERY = 64the preparer declines the checkpoint and the pass takes the existing full authoritative read:The forced reread amortizes the O(total) read to under 2% of passes; it reuses the untouched full-read path rather than adding a new one.
Verification
pnpm typecheckclean.